﻿
Imports System.Object
Imports VSModel
Imports Cls_Common
Imports System.IO
Imports System.Data
Partial Class FrontEnd_Control_Home_Gallery
    Inherits System.Web.UI.UserControl

#Region "Sub and function"
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then '
            LoadData()
        End If
    End Sub
    Private Sub LoadData()
        Using Data As New VSEntities
            Dim _lang As Integer = Session("LanguageId")
            Dim p = (From q In Data.Contents Where q.LanguageId = _lang And q.TypeId = 4 And q.StatusId = 3 And q.PublishedDate <= Now() And (q.eEffectiveDate >= Now() Or q.eEffectiveDate Is Nothing) Order By q.PublishedDate Descending
                     Select q).Take(4).ToList
            rptShow.DataSource = p
            rptShow.DataBind()
            ' hplMore.NavigateUrl = MainDomain & "tin-tuc.html"
        End Using
    End Sub
#End Region
#Region "Event for control"
    Protected Sub rptShow_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptShow.ItemDataBound
        '  hplTitle.NavigateUrl = MainDomain & "tin-tuc-chi-tiet/" & h.QueryString & "-" & h.Id.ToString & ".html"
        Dim row = CType(e.Item.DataItem, VSModel.Content)
        Dim img As Image = CType(e.Item.FindControl("imgImage"), Image)

        Dim hplImg As HyperLink = CType(e.Item.FindControl("hplImg"), HyperLink)
        ' = CookedImageURL("80-80", row.Image.ToString)

        img.ImageUrl = CookedImageURL("109-84", row.Image.ToString)

        hplImg.NavigateUrl = MainDomain & row.MenuId.ToString & "/" & row.QueryString & "-" & row.Id.ToString & arrTypeLink(row.TypeId) & ".html"

    End Sub
#End Region
End Class
